unit ufrmmain;

{$mode objfpc}{$H+}

interface

uses
  Classes,
  SysUtils,
  Forms,
  Controls,
  Graphics,
  Dialogs,
  ExtCtrls,
  ComCtrls,
  StdCtrls;

type

  { Tfrmmain }

  Tfrmmain = class(TForm)
    imgLogo  : TImage;
    lblOS  : TLabel;
    lblCPU  : TLabel;
    lvClient  : TListView;
    mmoLog  : TMemo;
    pc  : TPageControl;
    pnlHead  : TPanel;
    sb  : TStatusBar;
    tmr  : TTimer;
    tsClient  : TTabSheet;
    tsSet  : TTabSheet;
    tsLog  : TTabSheet;
    procedure FormCreate(Sender  : TObject);
    procedure tmrTimer(Sender  : TObject);
  private

  public

  end;

var
  frmmain  : Tfrmmain;

implementation

{$R *.lfm}

uses
  mormot.core.os,
  mormot.core.perf,
  mormot.core.Text,
  rtcconn,
  udmsrv;

  { Tfrmmain }

procedure Tfrmmain.FormCreate(Sender  : TObject);
begin
  Caption := '测试管理系统服务器';
  lblos.left := imglogo.Width + 10;
  lblcpu.left := imglogo.Width + 10;
  lblos.Caption := osversiontext;
  lblcpu.Caption := cpuinfotext;
  with gconfig, ExeVersion.Version do
  begin
    pc.activepageindex := 0;
    {$ifndef DEBUG}
    tsset.tabvisible := False;
    {$endif}
    if values['AppTitle'] <> '' then
    begin
      Caption := values['AppTitle'];
      sb.panels[0].Text := values['AppUnit'];
      GetExecutableVersion;
      sb.panels[1].Text := format('%d.%d.%d.%d', [major, Minor, Release, build]);
    end;
  end;
end;

procedure Tfrmmain.tmrTimer(Sender  : TObject);
begin
  with sb, dmsrv.rtchs do
  begin
    panels[2].Text := kb(gdatain);
    panels[3].Text := kb(gdataout);
    panels[4].Text := format('%d/%d/%d', [rtcClientConnectionCount,
      rtcServerConnectionCount, rtcTotalConnectionCount]);
    panels[5].Text := TSynMonitorMemory.FreeAsText(True);
    panels[6].Text := format('%.2f', [TSystemUse.Current.Percent]);
  end;
end;

end.
